package com.sdw.message.action;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.sdw.message.service.TestService;
import com.sdw.message.util.JSONSender;
import com.sdw.message.util.StatusName;

@ParentPackage("message")
@Controller()
@Scope("session")
public class TestAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 6605704448595694420L;
	
	@Resource
	private TestService testService;
	
	@Action(value="obtainUserName")
	public void obtainUserName(){
		Map<String, Object> map = new HashMap<String, Object>();
		
		try{
			String userName = this.testService.obtainUserName();
			
			map.put("result", StatusName.Success);
			map.put("data", userName);
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			JSONSender.send(ServletActionContext.getResponse(), map);
		}
	}

}
